<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
</head>

<body>
  <%@ include file="/WEB-INF/include/header.jsp"%>
  <%@ include file="/WEB-INF/include/menu.jsp"%>

  <div class="container main-content report">
    <div class="panel panel-default x-panel x-panel-layout">
      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/report">报表</a></li>
          <li class="active">报表</li>
        </ol>
      </div>

      <div class="panel-body">
        <div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>

        <div class="col-xs-10 x-panel-layout-right">
          <form id="orders-search-form" class="form-horizontal" method="GET" action="${ctx.host}/signin-reports">
            <div class="x-breadcrumb-wrapper">
              <div class="x-breadcrumb clearfix">
                <h2><i class="glyphicon glyphicon-fire"></i>&nbsp;&nbsp;<span>报表&nbsp;-&nbsp;未签到报表</span></h2>
                <c:if test="${not currentPrincipal.customerServer and not currentPrincipal.onlineCoach and not currentPrincipal.creditProductManager}">
                  <div class="pull-right">
                    <c:choose>
                      <c:when test="${not empty currentPrincipal.site}">
                        <span class="current-branchCode">${currentPrincipal.site.name}</span>
                      </c:when>
                      <c:otherwise>
                        <select name="siteId">
                          <option value="">所有门店</option>
                          <c:forEach var="site" items="${persist.getSites(currentPrincipal.id)}">
                            <option value="${site.id}" ${site.id == param.siteId ? 'selected' : ''}>${site.name}</option>
                          </c:forEach>
                        </select>
                      </c:otherwise>
                    </c:choose>
                  </div>
                </c:if>
              </div>
            </div>
            <div class="form-horizontal clearfix" style="margin-bottom: 20px">
              <div class="btn-group pull-right">
                <a href="${ctx.host}/signin-reports/export-view" data-target="#report-export" data-toggle="modal" class="btn btn-default x-btn btn-shadow btn-shadow-default pull-right">导出</a>
              </div>
            </div>

            <div class="x-breadcrumb-wrapper top-margin-20" style="position: relative;">
              <input type="hidden" name="filter" value="true" >
              <div class="form-group x-form-group">
                <label class="col-xs-2 control-label">开始时间</label>
                <div class="col-xs-3" style="width: 30%;">
                  <input type="text" class="form-control date" name="beginDate" value="${empty param.beginDate ? beginDate : param.beginDate}" placeholder="开始时间"/>
                </div>
                <label class="col-xs-2 control-label">结束时间</label>
                <div class="col-xs-3" style="width: 30%;">
                  <input type="text" class="form-control date" name="endDate" value="${empty param.endDate ? endDate : param.endDate}" placeholder="结束时间"/>
                </div>
              </div>
              
              <div class="form-group x-form-group">
                <label class="col-xs-2 control-label">主教练</label>
                <div class="col-xs-3" style="width: 30%;">
                  <select name="coachId" class="form-control" data-live-search="true" data-size="5">
                    <option></option>
                    <c:forEach var="coach" items="${persist.coaches(currentPrincipal.id, param.siteId)}" >
                      <c:if test="${not coach.value.disabled}">
                        <option value="${coach.key}" ${coach.key == param.coachId ? 'selected' : ''}>${coach.value.name}</option>
                      </c:if>
                    </c:forEach>
                  </select>
                </div>
              </div>
              
              <div class="form-group x-form-group">
                <label class="col-xs-2 control-label">学员名称</label>
                <div class="col-xs-3" style="width: 30%;">
                  <input type="text" class="form-control" name="name" value="${param.name}" placeholder="支持模糊查询"/>
                </div>
                <label class="col-xs-2 control-label">学员手机号</label>
                <div class="col-xs-3" style="width: 30%;">
                  <input type="text" class="form-control" name="mobile" value="${param.mobile}" placeholder="支持模糊查询"/>
                </div>
              </div>
              
              <div class="x-breadcrumb-wrapper clearfix" style="position: relative; margin-top: 15px;">
                <div class="btn-group pull-right">
                  <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">查询</button>&nbsp;&nbsp;&nbsp;&nbsp;
                </div>
              </div>
            </div>
          </form>


          
          <div style="margin: 0 15px;">
            <table class="table table-striped table-hover x-table" style="margin-bottom:20px;">
              <thead>
                <tr>
                  <th>学员姓名</th>
                  <th>学员手机号</th>
                  <th>门店</th>
                  <th>课程类型</th>
                  <th>课时/剩余课时</th>
                  <th>主教练</th>
                  <th>课程状态</th>
                  <th class="text-center">操作</th>
                </tr>
              </thead>
              <tbody>
                <c:if test="${not empty courseRounds}">
                  <c:forEach var="courseRound" items="${courseRounds}">
                    <tr>
                      <td>${courseRound.student.name}</td>
                      <td>${courseRound.student.mobile}</td>
                      <td>${courseRound.site.name}</td>
                      <td>${courseRound.courseType.other}</td>
                      <td>
                        <c:choose>
                          <c:when test="${courseRound.courseType.year}">
                            ${courseRound.surplusDays}
                          </c:when>
                          <c:otherwise>
                            <c:choose>
                              <c:when test="${not empty courseRound.attrs['course_amount']}">
                                ${courseRound.attrs['course_amount'].value}/${courseRound.attrs['course_amount'].value-courseRound.finished}
                              </c:when>
                              <c:otherwise>
                                ${courseRound.course.hours}/${courseRound.course.hours-courseRound.finished}
                              </c:otherwise>
                            </c:choose>
                          </c:otherwise>
                        </c:choose>
                        
                      </td>
                      <td>${courseRound.coach.name}</td>
                      <td>${courseRound.courseStatus.description}</td>
                      <td class="text-center">
                        <a href="${ctx.host}/${courseRound.courseType.alias}-rounds/${courseRound.id}">详情</a>&nbsp;&nbsp;
                      </td>
                    </tr>
                  </c:forEach>
                </c:if>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>

  <d:resource root="${ctx.resource}/build" type="script" src="js/page/report/signin-report.js">
    <script type="text/javascript">
      require(['page/report/signin-report'],function(page){
        page.init({
          "today": '${today}'
        });
      })
    </script>
  </d:resource>
</body>
</html>